const app = getApp()
import {
  reqConsumerDeviceAdd,
  reqConsumerDeviceUpdate
} from '../../../../request/api.js'
import {
  showMsg
} from '../../../../utils/config.js'
Page({
    data: {
      gonzhonghao1: '/statics/images/gaojing/yangan.png',
      deviceName:"",
      deviceCode:"",
      roomId:"",
      pic:""
    },
  
    onLoad(options) {
      console.log(options,'options');
      this.setData({
        deviceCode:options.deviceCode,
        roomId:options.roomId,
        pic:options.pic,
        deviceName:options.deviceName,
      })
    },
  
    onShow() {
  
    },
 
   async goAdd(){
      const res = await reqConsumerDeviceUpdate({
        deviceCode:this.data.deviceCode,
        deviceName:this.data.deviceName,
        roomId:this.data.roomId
      })
      if (res.code != 20000) return showMsg(res.message)
      showMsg("添加设备成功", "success")
      app.globalData.isUpdateCIndex = true
      wx.setStorageSync('isUpdateCIndex', true);
      setTimeout(() => {
        wx.switchTab({
        url: '/pages/index/index',
      })
      }, 1500)
    },
  })